﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace HZ.DrugTrade.Web.Admin.SystemManage
{
    public partial class ComPrint : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["accountId"]))
                {
                    //获取该企业的信息
                    HZ.DrugTrade.Model.View.CompanySendPwd info = HZ.DrugTrade.BLLFactory.Factory.BLL_Company().GetCom(Request.QueryString["accountId"].ToString());
                    int flag = 0;
                    HZ.DrugTrade.Model.View.CompanySendPwd outResult = new HZ.DrugTrade.Model.View.CompanySendPwd();
                    string sendFlag = info.IsSend.Value.ToString();
                    try
                    {
                        //发放企业密码
                        //if (sendFlag == "0")
                        //{
                            info.SendOperator = CurrentAccount.GetUser().UserName;
                            try
                            {
                                flag = HZ.DrugTrade.BLLFactory.Factory.BLL_Company().SendComAccountPWD(info, out outResult);
                                if (flag == 1)
                                {

                                    Session["result"] = outResult;
                                    HZ.Web.WebUtil.RedirectByScript("ComPwdPrint.aspx");
                                }
                                else
                                {
                                    HZ.Web.WebUtil.Alert("获取数据出错！");
                                    Response.Write("<script>window.close();</script>");
                                }
                            }
                            catch (Exception ex)
                            {
                                
                                throw;
                            }
                            
                        //}
                        //else
                        //{
                        //    HZ.Web.WebUtil.Alert("用户名已发放，不能重复操作！");
                        //    Response.Write("<script>window.close();</script>");
                        //}
                    }
                    catch
                    {
                        HZ.Web.WebUtil.Alert("出错！请联系管理员！", this);
                    }
                }
            }
        }
    }
}
